
import { _decorator, Component, Node, Sprite, SpriteFrame, UITransform } from 'cc';
import { TILE_TYPE_ENUM } from '../../Enum';
const { ccclass, property } = _decorator;
export const TILE_WIDTH =55;
export const TILE_HEIGHT=55;
@ccclass('TileManager')
export class TileManager extends Component {
    type:TILE_TYPE_ENUM;
    moveable:boolean;
    turnable:boolean;

    init(type:TILE_TYPE_ENUM, spriteFrame:SpriteFrame,i:number,j:number){
        this.type = type;
        if(this.type.includes("WALL")){
            this.moveable=false;
            this.turnable=false;
        }else if(this.type.includes("CLIFF")){
            this.moveable=true;
            this.turnable=false;
        }else if(this.type === TILE_TYPE_ENUM.FLOOR){
            this.moveable=true;
            this.turnable=true;
        }

        const sprite =this.addComponent(Sprite)
        sprite.spriteFrame = spriteFrame;
        const transfrom = this.getComponent(UITransform);
        transfrom.setContentSize(TILE_WIDTH,TILE_HEIGHT);
        this.node.setPosition(i*TILE_WIDTH,-j*TILE_HEIGHT);
    }

}


